package com.lzp.aop.strategy;

import com.lzp.aop.service.impl.AopTryCallOtherInterfaceImpl;
import com.lzp.aop.service.impl.ExtendTestServiceImpl;
import com.lzp.aop.service.impl.TestServiceImpl;
import com.lzp.aop.service.impl.ThreeExtendTestServiceImpl;

import java.util.Objects;

/**
 * @author : lzp
 * @version 1.0
 * @date : 2022/8/30 11:11
 * @apiNote : 策略枚举
 */
public enum ServiceEnum {

    /**
     * 这是继承二号实现
     */
    Service_1(1, TestServiceImpl.class.getSimpleName()),
    Service_2(2, ExtendTestServiceImpl.class.getSimpleName()),
    Service_3(3, ThreeExtendTestServiceImpl.class.getSimpleName()),
    Service_4(4,AopTryCallOtherInterfaceImpl.class.getSimpleName());

    int type;
    String name;

    public static String getNameByType(Integer type){
        for (ServiceEnum value : values()) {
            if (Objects.equals(value.getType(),type)) {
                return value.getName();
            }
        }
        return null;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    ServiceEnum(int type, String name) {
        this.type = type;
        this.name = name;
    }
}
